﻿#include <iostream>

using namespace std;

class Solution
{
public:
    // 67. 二进制求和
    string addBinary(string a, string b)
    {
        string ret;

        int cur1 = a.size() - 1, cur2 = b.size() - 1, t = 0;
        while (cur1 >= 0 || cur2 >= 0 || t)
        {
            if (cur1 >= 0)
                t += a[cur1--] - '0';
            if (cur2 >= 0)
                t += b[cur2--] - '0';
            ret += t % 2 + '0';
            t /= 2;
        }

        reverse(ret.begin(), ret.end());
        return ret;
    }
};

int main()
{
    string a = "1101";
    string b = "1010";
    cout << Solution().addBinary(a, b) << endl;

    return 0;
}